package com.siwei.mes.entity.experiment.concreteAdmixture;

import com.alibaba.fastjson.JSONObject;
import com.siwei.mes.common.util.JsonUtils;
import com.siwei.mes.entity.experiment.slag.SlagSsl;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @Description: 外加剂-沁水率比
 * @Version: 1.0
 * @author: YANGKE
 * @date: 2024/02/25 21:29
 */
@Data
@Accessors(chain = true)
public class ConcreteAdmixtureQslb {
    @ApiModelProperty(value = "单项结论")
    private String dxjl = "";
    @ApiModelProperty(value = "沁水率比")//1
    private String qslb = "";
    @ApiModelProperty(value = "基准混泥土平均值")
    private String jzhntpjz = "";
    @ApiModelProperty(value = "受检混泥土平均值")
    private String sjhntpjz = "";
    @ApiModelProperty(value = "受检混泥土信息")
    private List<ConcreteAdmixtureQslb.SjhntqslInfoList> sjhntqslInfoList = Collections.singletonList(new ConcreteAdmixtureQslb.SjhntqslInfoList());

    @Data
    @Accessors(chain = true)
    @ApiModel("受检混凝土泌水率信息")
    public static class SjhntqslInfoList {
        private SubSjhntqslInfo subSjhntqslInfo = new SubSjhntqslInfo();
    }

    @Data
    @Accessors(chain = true)
    @ApiModel("受检混凝土泌水率详细信息")
    public static class SubSjhntqslInfo {
        @ApiModelProperty(value = "检测日期")
        private String jcrq;
        @ApiModelProperty(value = "加水时间")
        private String jssj;
        @ApiModelProperty(value = "基准混泥土泌水总量")
        private String jzhntqszl;
        @ApiModelProperty(value = "受检混泥土泌水总量")
        private String sjhntqszl;
        @ApiModelProperty(value = "基准筒重")
        private String jztz;
        @ApiModelProperty(value = "基准筒+试样")
        private String jztjsy;
        @ApiModelProperty(value = "基准试样净重")
        private String jzsyjz;
        @ApiModelProperty(value = "基准拌合物用水量")
        private String jzbhwysl;
        @ApiModelProperty(value = "基准拌合物总质量")
        private String jzbhwzzl;
        @ApiModelProperty(value = "基准泌水率")
        private String jzqsl;
        @ApiModelProperty(value = "受检筒重")
        private String sjtz;
        @ApiModelProperty(value = "受检筒+试样")
        private String sjtjsy;
        @ApiModelProperty(value = "受检试样净重")
        private String sjsyjz;
        @ApiModelProperty(value = "受检拌合物用水量")
        private String sjbhwysl;
        @ApiModelProperty(value = "受检拌合物总质量")
        private String sjbhwzzl;
        @ApiModelProperty(value = "受检泌水率")
        private String sjqsl;
        private List<SubSjhntqslInfoList> subSjhntqslInfoList = Collections.singletonList(new SubSjhntqslInfoList());
    }

    @Data
    @Accessors(chain = true)
    @ApiModel("受检混凝土泌水率详细信息")
    public static class SubSjhntqslInfoList {
        @ApiModelProperty(value = "基准混泥土时间")
        private String jzhntsj = "";
        @ApiModelProperty(value = "受检混凝土时间")
        private String sjhntsj = "";
        @ApiModelProperty(value = "基准混泥土泌水量")
        private String jzhntqsl = "";
        @ApiModelProperty(value = "受检混泥土泌水量")
        private String sjhntqsl = "";
    }

    /**
     * 字符串转成对象 然后再转成json
     *
     * @param object
     * @return
     */
    private static JSONObject toJsonObject(Object object) {
        ConcreteAdmixtureQslb entity = new ConcreteAdmixtureQslb();
        if (object == null) {
            return JsonUtils.beanToObject(entity);
        }
        if (object instanceof String) {
            entity = JsonUtils.getObject((String) object, ConcreteAdmixtureQslb.class);
        } else if (object instanceof JSONObject) {
            entity = JsonUtils.getObject((JSONObject) object, ConcreteAdmixtureQslb.class);
        }
        return JsonUtils.beanToObject(entity);
    }

    public static String checkIsMust(JSONObject objJson, String name) {
        if (objJson.isEmpty()) {
            return null;
        }
        ConcreteAdmixtureQslb entity = JsonUtils.getObject(objJson, ConcreteAdmixtureQslb.class);
        if (entity == null) {
            return "存在必检项(" + name + ")未检测，请先检测！";
        }
        if (StringUtils.isBlank(entity.getQslb()) || "null".equals(entity.getQslb())) {
            return "存在必检项(" + name + ")未检测，请先检测！";
        }
        return null;
    }

    public static void setValue(ConcreteAdmixtureQslb entity, Map<String, Object> data) {
        if(data.get("AVGMSL1") != null){
            entity.setJzhntpjz(data.get("AVGMSL1").toString());
        }
        if(data.get("AVGMSL2") != null){
            entity.setSjhntpjz(data.get("AVGMSL2").toString());
        }
        if(data.get("AVGMSLB") != null){
            entity.setQslb(data.get("AVGMSLB").toString());
        }
        if(data.get("Conclusion") != null){
            entity.setDxjl(data.get("Conclusion").toString());
        }
        List<ConcreteAdmixtureQslb.SjhntqslInfoList> sjhntqslInfoList = new ArrayList<>();
        ConcreteAdmixtureQslb.SjhntqslInfoList sjhntqslInfo = new ConcreteAdmixtureQslb.SjhntqslInfoList();
        ConcreteAdmixtureQslb.SubSjhntqslInfo sub = new ConcreteAdmixtureQslb.SubSjhntqslInfo();
        if(data.get("S1VW") != null){
            sub.setSjhntqszl(data.get("S1VW").toString());
        }
        if(data.get("S1W") != null){
            sub.setSjbhwysl(data.get("S1W").toString());
        }
        if(data.get("S1G") != null){
            sub.setSjbhwzzl(data.get("S1G").toString());
        }
        if(data.get("S1GW") != null){
            sub.setSjsyjz(data.get("S1GW").toString());
        }
        if(data.get("S1B") != null){
            sub.setSjqsl(data.get("S1B").toString());
        }

        if(data.get("S4VW") != null){
            sub.setJzhntqszl(data.get("S4VW").toString());
        }
        if(data.get("S4W") != null){
            sub.setJzbhwysl(data.get("S4W").toString());
        }
        if(data.get("S4G") != null){
            sub.setJzbhwzzl(data.get("S4G").toString());
        }
        if(data.get("S4GW") != null){
            sub.setJzsyjz(data.get("S4GW").toString());
        }
        if(data.get("S4B") != null){
            sub.setJzqsl(data.get("S4B").toString());
        }
        sjhntqslInfo.setSubSjhntqslInfo(sub);
        sjhntqslInfoList.add(sjhntqslInfo);

        ConcreteAdmixtureQslb.SjhntqslInfoList sjhntqslInfo2 = new ConcreteAdmixtureQslb.SjhntqslInfoList();
        ConcreteAdmixtureQslb.SubSjhntqslInfo sub2 = new ConcreteAdmixtureQslb.SubSjhntqslInfo();
        if(data.get("S2VW") != null){
            sub2.setSjhntqszl(data.get("S2VW").toString());
        }
        if(data.get("S2W") != null){
            sub2.setSjbhwysl(data.get("S2W").toString());
        }
        if(data.get("S2G") != null){
            sub2.setSjbhwzzl(data.get("S2G").toString());
        }
        if(data.get("S2GW") != null){
            sub2.setSjsyjz(data.get("S2GW").toString());
        }
        if(data.get("S2B") != null){
            sub2.setSjqsl(data.get("S2B").toString());
        }
        if(data.get("S5VW") != null){
            sub2.setJzhntqszl(data.get("S5VW").toString());
        }
        if(data.get("S5W") != null){
            sub2.setJzbhwysl(data.get("S5W").toString());
        }
        if(data.get("S5G") != null){
            sub2.setJzbhwzzl(data.get("S5G").toString());
        }
        if(data.get("S5GW") != null){
            sub2.setJzsyjz(data.get("S5GW").toString());
        }
        if(data.get("S5B") != null){
            sub2.setJzqsl(data.get("S5B").toString());
        }
        sjhntqslInfo.setSubSjhntqslInfo(sub2);
        sjhntqslInfoList.add(sjhntqslInfo2);

        ConcreteAdmixtureQslb.SjhntqslInfoList sjhntqslInfo3 = new ConcreteAdmixtureQslb.SjhntqslInfoList();
        ConcreteAdmixtureQslb.SubSjhntqslInfo sub3 = new ConcreteAdmixtureQslb.SubSjhntqslInfo();
        if(data.get("S3VW") != null){
            sub3.setSjhntqszl(data.get("S3VW").toString());
        }
        if(data.get("S3W") != null){
            sub3.setSjbhwysl(data.get("S3W").toString());
        }
        if(data.get("S3G") != null){
            sub3.setSjbhwzzl(data.get("S3G").toString());
        }
        if(data.get("S3GW") != null){
            sub3.setSjsyjz(data.get("S3GW").toString());
        }
        if(data.get("S3B") != null){
            sub3.setSjqsl(data.get("S3B").toString());
        }
        if(data.get("S6VW") != null){
            sub3.setJzhntqszl(data.get("S6VW").toString());
        }
        if(data.get("S6W") != null){
            sub3.setJzbhwysl(data.get("S6W").toString());
        }
        if(data.get("S6G") != null){
            sub3.setJzbhwzzl(data.get("S6G").toString());
        }
        if(data.get("S6GW") != null){
            sub3.setJzsyjz(data.get("S6GW").toString());
        }
        if(data.get("S6B") != null){
            sub3.setJzqsl(data.get("S6B").toString());
        }
        sjhntqslInfo.setSubSjhntqslInfo(sub3);
        sjhntqslInfoList.add(sjhntqslInfo3);

    }
}
